package Leason3;

import java.util.Scanner;

public class three {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		System.out.println("How many days have this month?");
		
		int days = sc.nextInt();
		int day[] = new int [days];
		int temperature;
		
		int tempSum = 0;
		int avgTemp = 0;
		
		int counter = 0;
		int index = 0;
		
		for(int i = 0; i<day.length; i++)
		{
			System.out.println("What is the temperature of day " + (i+1));
			temperature = sc.nextInt();
			day[i] = temperature;
			
			tempSum += temperature;
		}
		
		int lowTemp = tempSum;
		int ind = 0;
		int dayCount = 0;
		
		avgTemp = tempSum / days;

		for(int i = 0; i < days; i++)
		{
			
			if(day[i] < avgTemp)
			{
				counter++;
				if (counter>index)
				{
					index=counter;
				}
			}
			else
			{
				counter=0;
			}
			if(day[i] < lowTemp)
			{
				lowTemp = day[i];
				ind++;
				if(ind > dayCount)
				{
					dayCount = ind;
				}
			}
			else
			{
			ind = 0;
			lowTemp=tempSum;
			}	
		}
		
		System.out.println("The avg temperature of this month is " + avgTemp);
		
		System.out.println("There are "+index+" sequence cold days");
		
		System.out.println("The longhest lowering temperatures period was "+dayCount+" day(s)");
	}

}
